package me.zk.practice1.hw;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zhangkai
 * @date 2023/8/7 10:11
 */
public class HWBJ28 {
    //1
    //-1 0 1 1 1 0 1 0 1 -1 1
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = Integer.parseInt(scanner.nextLine());

        String s = scanner.nextLine();

        int[] nums = Arrays.stream(s.split(" ")).mapToInt(Integer::parseInt).toArray();


        //记录最大连续值
        int max = Integer.MIN_VALUE;
        int index = -1;

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) {
                int l = i-1,r=i+1;
                while (l>=0) {
                    if (nums[l]!=a){
                       break;
                    }
                    l--;
                }
                while (r<=nums.length-1) {
                    if (nums[r]!=a) {
                     break;
                    }
                    r++;
                }
                int len = r-l-1;
                if (len > max && len<=5) {
                    max = len;
                    index = i;
                } else if (len == max) {
                    int h = nums.length/2;
                    if (Math.abs(h-i) < Math.abs(h-index)) {
                        index = i;
                    }
                }

            }

        }
        System.out.println(index);

    }

}
